package com.whq.knowverywell.adapter;

import java.util.List;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.whq.knowverywell.R;
import com.whq.knowverywell.util.LogUtil;

public class ProductSearchAdapter extends BaseAdapter {
	private static final String TAG = ProductSearchAdapter.class.getSimpleName(); 
	
	private Activity ctx;
	private List list;
	private LayoutInflater inflater;
	
	public ProductSearchAdapter(Activity ctx, List list) {
		this.ctx = ctx;
		this.list = list;
		this.inflater = LayoutInflater.from(ctx);
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return 4;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LogUtil.d(TAG, "position---------[" + position + "]");
		
		HuizongViewHolder huizongViewHolder = null;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.huizong_item, null);
			huizongViewHolder = new HuizongViewHolder();
			huizongViewHolder.mallTextView = (TextView) convertView.findViewById(R.id.mall_textview);
			huizongViewHolder.sellAmountTextView = (TextView) convertView.findViewById(R.id.sell_amount_textview);
			huizongViewHolder.sellCountTextView = (TextView) convertView.findViewById(R.id.sell_count_textview);
			huizongViewHolder.synchronousSellAmountTextView = (TextView) convertView.findViewById(R.id.synchronous_sell_amount_textview);
			huizongViewHolder.synchronousSellCountTextView = (TextView) convertView.findViewById(R.id.synchronous_sell_count_textview);
			
			convertView.setTag(huizongViewHolder);
		} else {
			huizongViewHolder = (HuizongViewHolder) convertView.getTag();
		}
		
		
		return convertView;
	}
	
	class HuizongViewHolder {
		TextView mallTextView, sellAmountTextView,
				synchronousSellAmountTextView, sellCountTextView,
				synchronousSellCountTextView;
	}

}
